package org.pulloid.android;

import org.pulloid.ElementContext;

public class AndroidElementContext extends ElementContext<Record> {
	
	PulloidAdapter adapter;
	
	AndroidElementContext(AndroidRootContext parent, String name, PulloidAdapter a) {
		super(parent, name);
		this.adapter = a;
	}
	
	AndroidElementContext(AndroidElementContext parent, String name, PulloidAdapter a) {
		super(parent, name);
		this.adapter = a;
	}
	
	@Override
	public AndroidElementContext selectElement(String name) {
		AndroidElementContext ctx = new AndroidElementContext(this, name, this.adapter);
		selectElement(ctx);
		return ctx;
	}
	
	@Override
	public ElementContext<Record> createField(String name) {
		throw new UnsupportedOperationException("Use createField(int) with a view resource ID instead");
	}
	public AndroidElementContext createField(int resourceId) {
		super.createField(String.valueOf(resourceId));
		return this;
	}
	
	@Override
	public ElementContext<Record> createField(String name, Class<?> type) {
		throw new UnsupportedOperationException("Use createField(int, Class<?>) with a view resource ID instead");
	}
	public AndroidElementContext createField(int resourceId, Class<?> type) {
		super.createField(String.valueOf(resourceId), type);
		return this;
	}
	
	@Override
	public ElementContext<Record> createFieldOnAttribute(String fieldName, String attributeName) {
		throw new UnsupportedOperationException("Use createFieldOnAttribute(int, String) with a view resource ID instead");
	}
	public AndroidElementContext createFieldOnAttribute(int resourceId, String attributeName) {
		super.createFieldOnAttribute(String.valueOf(resourceId), attributeName);
		return this;
	}
	
	@Override
	public ElementContext<Record> createFieldOnAttribute(String fieldName, String attributeName, Class<?> type) {
		throw new UnsupportedOperationException("Use createFieldOnAttribute(int, String, Class<?>) with a view resource ID instead");
	}
	public AndroidElementContext createFieldOnAttribute(int resourceId, String attributeName, Class<?> type) {
		super.createFieldOnAttribute(String.valueOf(resourceId), attributeName, type);
		return this;
	}
	
	
	
	
	@Override
	public AndroidCursorDef defineCursor(Class<Record> cursorType) {
		throw new UnsupportedOperationException("Use defineCurosr() instead");
	}
	
	@Override
	public AndroidCursorDef defineCursor() {
		AndroidCursorDef def = new AndroidCursorDef(this);
		setCursorDef(def);
		return def;
	}


}
